package org.tlipoca.smsteamuserstore.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.genntii.smcommon.result.PageResult;
import org.genntii.smcommon.result.Result;
import org.genntii.smdomain.entity.SteamUserStore;
import org.genntii.smdomain.vo.SteamUserStoreMessageVO;
import org.genntii.smdomain.vo.SteamUserStoreVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.tlipoca.smsteamuserstore.service.SteamUserStoreService;

import java.util.ArrayList;

@Tag(name = "用户库存")
@RestController
@RequestMapping("/steam_user_store")
public class SteamUserStoreController {

    @Autowired
    private SteamUserStoreService steamUserStoreService;

    @Operation(summary = "根据steamid获取用户库存")
    @GetMapping("/{steamid}")
    public Result<ArrayList<SteamUserStore>> getSteamUserStoreBySteamId(@PathVariable Long steamid) {
        return Result.success(steamUserStoreService.getSteamUserStoreBySteamIdService(steamid));
    }

    @GetMapping("/getStore/{steamid}")
    public PageResult<SteamUserStoreMessageVO> steamUserStoreMessageVO(@PathVariable Long steamid,
                                                                       @RequestParam("pageNum") Integer pageNum,
                                                                       @RequestParam("pageSize") Integer pageSize){
        return steamUserStoreService.getSteamUserStoreDetail(steamid, pageNum, pageSize);
    }

    @PutMapping("/update/{steamid}")
    @Operation(summary = "根据steamid更新用户库存信息")
    public Result updateSteamUserStoreBySteamId(@PathVariable Long steamid) {
        steamUserStoreService.updateSteamUserStoreBySteamIdService(steamid);
        return Result.success();
    }
    @Operation(summary = "获得游戏数量、时长")
    @GetMapping("/message/{steamid}")
    public Result<SteamUserStoreVO> getPlayerPlayedMessage(@PathVariable String steamid){
        return Result.success(steamUserStoreService.getPlayerPlayedMessage(steamid));
    }

}
